package com.demo.salary.payrolldomain;


import com.demo.salary.payrollimplementation.NoAffiliation;
import com.demo.salary.PayCheck;

import java.time.LocalDate;

public class Employee {

    private int empId;
    private String name;
    private String address;

    private PaymentClassification classification;
    private PaymentSchedule schedule;
    private PayMethod method;
    private Affiliation affiliation = new NoAffiliation();

    public Employee(int empId, String name, String address) {
        this.empId = empId;
        this.name = name;
        this.address = address;
    }

    public void setAffiliation(Affiliation affiliation) {
        this.affiliation = affiliation;
    }

    public boolean isPayDate(LocalDate itsPayDate) {
        return schedule.isPayDate(itsPayDate);
    }
    public LocalDate getPayPeriodStartDate(LocalDate payDate) {
        return schedule.getPayPeriodStartDate(payDate);
    }
    public void payDay(PayCheck pc) {
        double grossPay = classification.calculatePay(pc);
        double deductions = affiliation.calculateDeductions(pc);

        pc.setGrossPay(grossPay);
        pc.setDeductions(deductions);
        pc.setNetPay(grossPay-deductions);

        method.pay(pc);
    }



    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public PaymentClassification getClassification() {
        return classification;
    }

    public void setClassification(PaymentClassification classification) {
        this.classification = classification;
    }

    public PaymentSchedule getSchedule() {
        return schedule;
    }

    public void setSchedule(PaymentSchedule schedule) {
        this.schedule = schedule;
    }

    public PayMethod getMethod() {
        return method;
    }

    public void setMethod(PayMethod method) {
        this.method = method;
    }

    public Affiliation getAffiliation() {
        return affiliation;
    }
}
